# _*_ coding:utf-8 _*_

import xadmin

from .models import Course, Lesson, Video, CourseResource

# Create your models here.


class CourseAdmin(object):
    list_display = ["name", "desc", "detail", "is_banner", "degree", "learn_times", "students", "fav_nums", "image", "click_nums", "add_time"]
    search_fields = ["name", "desc", "detail", "is_banner", "degree", "learn_times", "students", "fav_nums", "image", "click_nums"]
    list_filter = ["name", "desc", "detail", "is_banner", "degree", "learn_times", "students", "fav_nums", "image", "click_nums", "add_time"]


class LessonAdmin(object):
    list_display = ["course", "name", "learn_times", "add_time"]
    search_fields = ["course__name", "name", "learn_times"]
    list_filter = ["course__name", "name", "learn_times", "add_time"]

    # list_filter = ["course"]
    # 过滤course的主键


class VideoAdmin(object):
    list_display = ["lesson", "name", "learn_times", "url", "add_time"]
    search_fields = ["lesson__name", "name", "learn_times", "url"]
    list_filter = ["lesson__name", "name", "learn_times", "url", "add_time"]


class CourseResourceAdmin(object):
    list_display = ["course", "name", "download", "add_time"]
    search_fields = ["course__name", "name", "download"]
    list_filter = ["course__name", "name", "download", "add_time"]


xadmin.site.register(Course, CourseAdmin)
xadmin.site.register(Lesson, LessonAdmin)
xadmin.site.register(Video, VideoAdmin)
xadmin.site.register(CourseResource, CourseResourceAdmin)
